#!/usr/bin/env python
# coding: utf-8

import sys
import uuid

reload(sys)
sys.setdefaultencoding('utf-8')
from wxbot import *


class MyWXBot(WXBot):
    def handle_msg_all(self, msg):
        if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
            content = msg['content']['data']
            if u'我要检测' == content or u'我要檢測' == content:
                uid = str(uuid.uuid1())
                self.session.get("http://localhost:9999/admin/webchatbot/createBot?uid=" + uid)
                # 创建完成以后,发送图片给好友进行扫描
                img = "/Users/sunfeihu/IdeaProjects/splatform/webchatbot/src/main/webapp/corpse_bot/temp/" + uid + ".png"
                time.sleep(1)
                self.send_img_msg_by_uid(img, msg['user']['id'])


def main():
    bot = MyWXBot()
    bot.DEBUG = True
    bot.conf['qr'] = 'png'
    bot.run()


if __name__ == '__main__':
    main()
